#ifndef CCONSOLE_H
#define CCONSOLE_H

#include <windows.h>
#include "ZenEngine.h"
#include "Command.h"
#include "Entry.h"

#define interface struct

class CConsole;

interface ICommandHandler
{
	virtual int ConsoleParser(CConsole &console, CCommand* pCommand ) = 0;
};

class CConsole
{
public:
	static CZenEngine			zen;

protected:
	int					m_Width;
	int					m_Height;
	BOOL				m_bInitialized;
	BOOL				m_bVisible;
	BOOL				m_bParserCallback;
	LPDIRECT3DSURFACE8	m_pConsoleSurface;
	LPDIRECT3DSURFACE8	m_pConsoleBackgroundSurf;
	LPDIRECT3DSURFACE8	m_pTargetSurface;
	LPDIRECT3DDEVICE8	m_pDevice;
	CEntry *			m_pActiveEntry;
	CEntry *			m_pEntryList;

public:
	enum ANIM{Up, Down, None}	m_Animation;;
	ICommandHandler	*			m_pCommandHandler;

public:
	CConsole();
	~CConsole();

	void Shutdown();
	HRESULT Initialize(LPDIRECT3DDEVICE8 pDevice, LPDIRECT3DSURFACE8 pTargetSurface);
	void Render();
	BOOL GetVisibility();
	void SetVisibility(BOOL bVisible);
	void OutputString(char * pString);
	void Clear();
	int OnChar(char Key);
	int OnKeyDown(WPARAM wParam);
	void PreParse(char * pstrText, CCommand * pCommand);
	void SetParserCallback(ICommandHandler	*);

protected:
	void RotateEntries();
};

#endif
